using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input.Touch;
using BlueGameComponent;

namespace TouchExplode
{
    class LogoScreen:BaseScreen
    {
        Random rand;
        Color FontColor = Color.Black;
        Texture2D logo;
        static string LogoString = "Gel Studio";
        public LogoScreen()
        {
            rand = new Random();
            TransitionOnTime = TimeSpan.FromSeconds(1.5);
            TransitionOffTime = TimeSpan.FromSeconds(0.8);
        }
        public override void  LoadContent()
        {
 	        base.LoadContent();
            logo = ScreenManager.Game.Content.Load<Texture2D>("Textures/GELlogo");
        }
        
        public override void Draw(GameTime gameTime)
        {
            SpriteBatch spriteBatch = ScreenManager.SpriteBatch;
            spriteBatch.Begin();
            /*
            Color color = Color.White;
            spriteBatch.Draw(ScreenManager.blankTexture, new Rectangle(0, 0, ScreenManager.ViewPort.Width, ScreenManager.ViewPort.Height), color);

            Vector2 vec = ScreenManager.Font.MeasureString(LogoString);
            vec /= 2;
            if ( 0==gameTime.TotalGameTime.Ticks % 10)
            {
                FontColor.R = (byte)rand.Next(125);
                FontColor.G = (byte)rand.Next(125);
                FontColor.B = (byte)rand.Next(125);
            }
            spriteBatch.DrawString(ScreenManager.Font, LogoString, new Vector2(ScreenManager.ViewPort.Width, ScreenManager.ViewPort.Height) / 2 - vec, FontColor * TransitionAlpha);
             */
            Color color = Color.White;
            spriteBatch.Draw(ScreenManager.blankTexture, new Rectangle(0, 0, ScreenManager.ViewPort.Width, ScreenManager.ViewPort.Height), color);

            Vector2 vec = new Vector2(ScreenManager.ViewPort.Width, ScreenManager.ViewPort.Height)/2;
            vec.X -= logo.Width/2;
            vec.Y -= logo.Height/2;
            spriteBatch.Draw(logo, vec, FontColor * TransitionAlpha);
            spriteBatch.End();
        }
        public override void Update(GameTime gameTime, bool otherScreenHasFocus, bool coveredByOtherScreen)
        {
            base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);
            
            if (IsActive)
            {
                if (gameTime.TotalGameTime > TimeSpan.FromSeconds(3) )
                {
                    ExitScreen();
                }
            }
        }
        public override void OnExit()
        {
            ScreenManager.AddScreen(new MainMenuScreen(), null);
        }
    }
}
